【时间序列预测】最小均方(LMS)算法时间序列预测【含Matlab源码 1335期】

您所在的位置:网站首页 lms MATLAB代码 【时间序列预测】最小均方(LMS)算法时间序列预测【含Matlab源码 1335期】

【时间序列预测】最小均方(LMS)算法时间序列预测【含Matlab源码 1335期】

2024-02-01 06:23| 来源: 网络整理| 查看: 265

⛄一、运行结果

在这里插入图片描述 在这里插入图片描述 在这里插入图片描述

✅博主简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,Matlab项目合作可私信。 🍎个人主页:海神之光 🏆代码获取方式: 海神之光Matlab王者学习之路—代码获取方式 ⛳️座右铭:行百里者,半于九十。

更多Matlab仿真内容点击👇 Matlab图像处理(进阶版) 路径规划(Matlab) 神经网络预测与分类(Matlab) 优化求解(Matlab) 语音处理(Matlab) 信号处理(Matlab) 车间调度(Matlab)

⛄二、最小均方(LMS)算法简介

理论知识参考:最小均方算法(LMS)

⛄三、部分源代码

%% Mackey Glass Time Series Prediction Using Least Mean Square (LMS) % Author: 紫极神光 clc clear all close all

%% Loading Time series data % I generated a series y(t) for t = 0,1, . . . ,3000, using % mackey glass series equation with the following configurations: % b = 0.1, a = 0.2, Tau = 20, and the initial conditions y(t - Tau) = 0. load Dataset\Data.mat time_steps=2; teacher_forcing=1; % recurrent ARMA modelling with forced desired input after defined time steps %% Training and Testing datasets % For training Tr=Data(100:2500,1); % Selecting a Interval of series data t = 100~2500

% For testing Ts=Data(2500:3000,1); % Selecting a Interval of series data t = 2500~3000 Ys(Ts)=Data(Ts,2); % Selecting a chuck of series data y(t)

%% LMS Parameters

eta=5e-3; % Learning rate M=1; % Order of LMS filter

MSE=[]; % Initial mean squared error (MSE)

%% Learning weights of LMS (Training) tic % start for t=Tr(1):Tr(end)-time_steps U(1:end-1)=U(2:end); % Shifting of tap window

if (teacher_forcing==1) if rem(t,time_steps)==0 || (t==Tr(1)) U(end)=Yr(t); % Input (past/current samples) else U(end)=Yp(t-1); % Input (past/current samples) end else U(end)=Yr(t); % Input (past/current samples) end e(t)=Yr(t+time_steps)-Yp(t); % Error in predicted output W=W+eta*e(t)*U; % Weight update rule of LMS

end training_time=toc; % total time including training and calculation of MSE

%% Prediction of a next outcome of series using previous samples (Testing) tic % start U=U*0; % Reinitialization of taps (optional) for t=Ts(1):Ts(end)-time_steps+1 U(1:end-1)=U(2:end); % Shifting of tap window

if (teacher_forcing==1) if rem(t,time_steps)==0 || (t==Ts(1)) U(end)=Ys(t); % Input (past/current samples) else U(end)=Yp(t-1); % Input (past/current samples) end else Yp(t)=W'*U; % Calculating output (future value) e(t)=Ys(t+time_steps-1)-Yp(t); % Error in predicted output E(t)=e(t).^2; % Current mean squared error (MSE)

end testing_time=toc; % total time including testing and calculation of MSE

%% Results figure(1) plot(Tr,10log10(E(Tr))); % MSE curve hold on plot(Ts(1:end-time_steps+1),10log10(E(Ts(1:end-time_steps+1))),‘r’); % MSE curve grid minor

title(‘Cost Function’); xlabel(‘Iterations (samples)’); ylabel(‘Mean Squared Error (MSE)’); legend(‘Training Phase’,‘Test Phase’);

figure(2) plot(Tr(2M:end),Yr(Tr(2M:end))); % Actual values of mackey glass series hold on plot(Tr(2M:end),Yp(Tr(2M:end))‘,‘r’) % Predicted values during training plot(Ts,Ys(Ts),’–b’); % Actual unseen data plot(Ts(1:end-time_steps+1),Yp(Ts(1:end-time_steps+1))‘,’–r’); % Predicted values of mackey glass series (testing) xlabel(‘Time: t’); ylabel(‘Output: Y(t)’); title(‘Mackey Glass Time Series Prediction Using Least Mean Square (LMS)’) ylim([min(Ys)-0.5, max(Ys)+0.5]) legend(‘Training Phase (desired)’,‘Training Phase (predicted)’,‘Test Phase (desired)’,‘Test Phase (predicted)’);

mitr=10log10(mean(E(Tr))); % Minimum MSE of training mits=10log10(mean(E(Ts(1:end-time_steps+1)))); % Minimum MSE of testing

display(sprintf(‘Total training time is %.5f, \nTotal testing time is %.5f \nMSE value during training %.3f (dB),\nMSE value during testing %.3f (dB)’, … training_time,testing_time,mitr,mits));

⛄四、matlab版本及参考文献

1 matlab版本 2014a

2 参考文献 [1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016. [2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.

3 备注 简介此部分摘自互联网,仅供参考,若侵权,联系删除

🍅 仿真咨询 1 各类智能优化算法改进及应用 生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化

2 机器学习和深度学习方面 卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断

3 图像处理方面 图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知

4 路径规划方面 旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化

5 无人机应用方面 无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配

6 无线传感器定位及布局方面 传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化

7 信号处理方面 信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化

8 电力系统方面 微电网优化、无功优化、配电网重构、储能配置

9 元胞自动机方面 交通流 人群疏散 病毒扩散 晶体生长

10 雷达方面 卡尔曼滤波跟踪、航迹关联、航迹融合



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3